Part Number Hot Search : 
1047607 C74LVX1 S8330MG 5257B 765000 HMC1114 TA0727A TPS5433
Product Description
Full Text Search
 

To Download HT46R4718DIP-A Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ht46r47 8-bit otp battery charger controller rev. 1.40 1 july 18, 2001 general description the device is an 8-bit high performance risc-like microcontroller designed for multi - ple i/o product applications. the device is par - ticularly suitable for use in products such as battery charger controllers and a/d applica- tions. a halt feature is included to reduce power consumption. the program and option memories can be elec - trically programmed, making the microcontrol - ler suitable for use in product development. features  operating voltage: f sys =4mhz: 3.3v~5.5v f sys =8mhz: 4.5v~5.5v  13 bidirectional i/o lines (max.)  1 interrupt input shared with an i/o line  8-bit programmable timer/event counter with overflow interrupt and 7-stage prescaler  on-chip crystal and rc oscillator  watchdog timer  2048  14 program memory prom  64  8 data memory ram  supports pfd for sound generation  halt function and wake-up feature reduce power consumption  up to 0.5  s instruction cycle with 8mhz system clock at v dd =5v  six-level subroutine nesting  4 channels 9-bit resolution (8-bit accuracy) a/d converter  1 channel (6+2)-bit pwm output shared with an i/o line  bit manipulation instruction  14-bit table read instruction  63 powerful instructions  all instructions in one or two machine cycles  low voltage reset function  18-pin dip/sop package
block diagram pin assignment ht46r47 rev. 1.40 2 july 18, 2001   
             
 
 
 
                      
    
             !                 "#$%&'#" (    ")*"&+    ")*"&+  ),-.#" -.#"",/. 0"%,0. !
   #+)"1 -$.",%.0)-  #*0$.#"    -$.",%.0)-  #%)2#"     3 0(.# " 0+ 0-* 4 #-#"&.)"      "#$%&'#"          
5
 5    
  6   7 3&--#'    )-8#".#"  /.0)-    6
pin description pin no. pin name i/o rom code option description 4~2 1 18 17 16, 15 pa0~pa2 pa3/pfd pa4/tmr pa5/int pa6, pa7 i/o pull-high wake-up pa3 or pfd bidirectional 8-bit input/output port. each bit can be configured as wake-up input by rom code option. software instructions determine the cmos output or schmitt trigger input with or without pull-high resistor (determined by pull-high options: bit option). the pfd, tmr and int are pin-shared with pa3, pa4 and pa5, respectively. 8 7 6 5 pb0/an0 pb1/an1 pb2/an2 pb3/an3 i/o pull-high bidirectional 4-bit input/output port. software in - structions determine the cmos output, schmitt trig - ger input with or without pull-high resistor (determined by pull-high options: bit option) or a/d in - put. once a pb line is selected as an a/d input (by using software control), the i/o function and pull-high resistor are disabled automatically. 9 vss  negative power supply, ground. 10 pd0/pwm i/o pull-high pd0 or pwm bidirectional i/o line. software instructions deter - mine the cmos output, schmitt trigger input with or without a pull-high resistor (determined by pull-high options: bit option). the pwm output function is pin-shared with pd0 (dependent on pwm options). 11 res i  schmitt trigger reset input. active low. 12 vdd  positive power supply 13 14 osc1 osc2 i o crystal or rc osc1, osc2 are connected to an rc network or a crystal (determined by rom code option) for the in- ternal system clock. in the case of rc operation, osc2 is the output terminal for 1/4 system clock. absolute maximum ratings supply voltage ...............v ss  0.3v to v ss +5.5v storage temperature ................  50  cto125  c input voltage.................v ss  0.3v to v dd +0.3v operating temperature ..............  40  cto85  c note: these are stress ratings only. stresses exceeding the range specified under  absolute maxi - mum ratings  may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged expo - sure to extreme conditions may affect device reliability. ht46r47 rev. 1.40 3 july 18, 2001
d.c. characteristics ta=25  c symbol parameter test conditions min. typ. max. unit v dd conditions v dd1 operating voltage  f sys =4mhz 3.3  5.5 v v dd2 operating voltage  f sys =8mhz 4.5  5.5 v i dd1 operating current (crystal osc) 3.3v no load, f sys =4mhz adc disable  1.3 3 ma 5v  35ma i dd2 operating current (rc osc) 3.3v no load, f sys =4mhz adc disable  1.3 3 ma 5v  35ma i dd3 operating current 5v no load, fsys=8mhz adc disable  48ma i adc only adc enable, others disable 3.3v no load  12ma 5v  24ma i stb1 standby current (wdt enabled) 3.3v no load, system halt  5  a 5v  10  a i stb2 standby current (wdt disabled) 3.3v no load, system halt  1  a 5v  2  a v ad a/d input voltage  0  v dd v v il1 input low voltage for i/o ports, tmr and int 3.3v  0  0.3v dd v 5v  0  0.3v dd v v ih1 input high voltage for i/o ports, tmr and int 3.3v  0.7v dd  v dd v 5v  0.7v dd  v dd v v il2 input low voltage (res ) 3.3v  0  0.4v dd v 5v  0  0.4v dd v v ih2 input high voltage (res ) 3.3v  0.9v dd  v dd v 5v  0.9v dd  v dd v v lvr low voltage reset  2.7 3.0 3.3 v i ol i/o port sink current 3.3v v ol =0.1v dd 48  ma 5v v ol =0.1v dd 10 20  ma i oh i/o port source current 3.3v v oh =0.9v dd  2  4  ma 5v v oh =0.9v dd  5  10  ma ht46r47 rev. 1.40 4 july 18, 2001
symbol parameter test conditions min. typ. max. unit v dd conditions r ph pull-high resistance 3.3v  40 60 80 k  5v  10 30 50 k  e ad a/d conversion error 5v  0.5 1 lsb a.c. characteristics ta=25  c symbol parameter test conditions min. typ. max. unit v dd conditions f sys1 system clock (crystal osc) 3.3v  400  4000 khz 5v  400  8000 khz f sys2 system clock (rc osc) 3.3v  400  4000 khz 5v  400  8000 khz f timer timer i/p frequency (tmr) 3.3v  0  4000 khz 5v  0  8000 khz t ad a/d clock period 5v  1  s t adc a/d conversion time  76  t ad t wdtosc watchdog oscillator 3.3v  43 86 168  s 5v  36 72 144  s t wdt1 watchdog time-out period (rc) 3.3v  2.8 5.6 11 s 5v 2.3 4.7 9.4 s t wdt2 watchdog time-out period (system clock)  2 17  2 18 t sys t res external reset low pulse width  1  s t sst system start-up timer period  wake-up from halt  1024  *t sys t int interrupt pulse width  1  s note: *t sys =1/f sys ht46r47 rev. 1.40 5 july 18, 2001
ht46r47 rev. 1.40 6 july 18, 2001 functional description execution flow the system clock for the microcontroller is de - rived from either a crystal or an rc oscillator. the system clock is internally divided into four non-overlapping clocks. one instruction cycle consists of four system clock cycles. instruction fetching and execution are pipelined in such a way that a fetch takes an in - struction cycle while decoding and execution takes the next instruction cycle. however, the pipelining scheme causes each instruction to ef - fectively execute in a cycle. if an instruction changes the program counter, two cycles are re - quired to complete the instruction. program counter  pc the program counter (pc) controls the se - quence in which the instructions stored in pro - gram prom are executed and its contents specify full range of program memory. after accessing a program memory word to fetch an instruction code, the contents of the program counter are incremented by one. the program counter then points to the memory word contain- ing the next instruction code. when executing a jump instruction, conditional skip execution, loading pcl register, subrou - tine call, initial reset, internal interrupt, exter - nal interrupt or return from subroutine, the pc manipulates the program transfer by loading the address corresponding to each instruction. the conditional skip is activated by instruc - tions. once the condition is met, the next in - struction, fetched during the current instruction execution, is discarded and a dummy cycle replaces it to get the proper in - struction. otherwise proceed with the next in - struction. the lower byte of the program counter (pcl) is a readable and writeable register (06h). moving data into the pcl performs a short jump. the destination will be within 256 loca - tions. when a control transfer takes place, an addi - tional dummy cycle is required. program memory  prom the program memory is used to store the pro- gram instructions which are to be executed. it also contains data, table, and interrupt entries, and is organized into 2048  14 bits, addressed by the program counter and table pointer.              # .% 3 
  9  :  ;#%,.#
 9  7:  # .% 3 
  9  <  :  ;#%,.#
 9  :  # .% 3 
  9  <  :  ;#%,.#
 9  <:  < <  1$.#+  ')%= 9)-'1:  execution flow
ht46r47 rev. 1.40 7 july 18, 2001 certain locations in the program memory are reserved for special usage:  location 000h this area is reserved for program initializa - tion. after chip reset, the program always be - gins execution at location 000h.  location 004h this area is reserved for the external inter - rupt service program. if the int input pin is activated, the interrupt is enabled and the stack is not full, the program begins execution at location 004h.  location 008h this area is reserved for the timer/event coun - ter interrupt service program. if a timer inter - rupt results from a timer/event counter overflow, and if the interrupt is enabled and the stack is not full, the program begins execution at location 008h.  location 00ch this area is reserved for the a/d converter in - terrupt service program. if an a/d converter interrupt results from an end of a/d conver - sion, and if the interrupt is enabled and the stack is not full, the program begins execution at location 00ch.  table location any location in the prom space can be used as look-up tables. the instructions "tabrdc [m]" (the current page, 1 page=256 words) and "tabrdl [m]" (the last page) transfer the contents of the lower-order byte to the specified data memory, and the higher-order byte to tblh (08h). only the destination of the lower-order byte in the table is mode program counter *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 initial reset 00000000000 external interrupt 00000000100 timer/event counter overflow 00000001000 a/d converter interrupt 00000001100 skip pc+2 loading pcl *10 *9 *8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0 return from subroutine s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter note: *10~*0: program counter bits s10~s0: stack register bits #10~#0: instruction code bits @7~@0: pcl bits >0.$ -? -?  ")*"&+ #+)"1  #80%# -0.0&'0@&.0)- ")*"&+  ; .# "- & ' - .# "", / . , > ") , .0- # 0+ #" 8#-. ),-.#" -.#"",/. ,>"),.0-# ))=7,/&>'#9 a )"2$: ))=7,/&>'#9 a )"2$:
).#b-"&-*#$(")+ .) ? ? ?    )-8#".#" -.#"",/. ,>"),.0-#  ? ? ? program memory
ht46r47 rev. 1.40 8 july 18, 2001 instruction table location *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 tabrdc [m] p10 p9 p8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 1 1 1 @7 @6 @5 @4 @3 @2 @1 @0 table location note: *10~*0: table location bits p10~p8: current program counter bits @7~@0: table pointer bits well-defined, the other bits of the table word are transferred to the lower portion of tblh, and the remaining 2 bits are read as "0". the table higher-order byte register (tblh) is read only. the table pointer (tblp) is a read/write register (07h), which indicates the table location. before accessing the table, the location must be placed in tblp. the tblh is read only and cannot be restored. if the main routine and the isr (interrupt service routine) both employ the table read instruc - tion, the contents of the tblh in the main routine are likely to be changed by the table read instruction used in the isr. errors can occur. in other words, using the table read in - struction in the main routine and the isr si - multaneously should be avoided. however, if the table read instruction has to be applied in both the main routine and the isr, the inter - rupt is supposed to be disabled prior to the ta - ble read instruction. it will not be enabled until the tblh has been backed up. all table related instructions require two cycles to com - plete the operation. these areas may function as normal program memory depending upon the requirements. stack register  stack this is a special part of the memory which is used to save the contents of the program coun- ter (pc) only. the stack is organized into 6 lev- els and is neither part of the data nor part of the program space, and is neither readable nor writeable. the activated level is indexed by the stack pointer (sp) and is neither readable nor writeable. at a subroutine call or interrupt ac- knowledgment, the contents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, signaled by a return instruction (ret or reti), the pro - gram counter is restored to its previous value from the stack. after a chip reset, the sp will point to the top of the stack. if the stack is full and a non-masked interrupt takes place, the interrupt request flag will be recorded but the acknowledgment will be inhib - ited. when the stack pointer is decremented (by ret or reti), the interrupt will be serviced. this feature prevents stack overflow allowing the programmer to use the structure more eas - ily. in a similar case, if the stack is full and a "call" is subsequently executed, stack over - flow occurs and the first entry will be lost (only the most recent 6 return addresses are stored). data memory  ram the data memory is designed with 85  8 bits. the data memory is divided into two func - tional groups: special function registers and general purpose data memory (64  8). most are read/write, but some are read only. the special function registers include the indi - rect addressing register (00h), timer/event counter (tmr;0dh), timer/event counter con- trol register (tmrc;0eh), program counter lower-order byte register (pcl;06h), memory pointer register (mp;01h), accumulator (acc;05h), table pointer (tblp;07h), table higher-order byte register (tblh;08h), status register (status;0ah), interrupt control reg- ister (intc;0bh), pwm data register (pwm;1ah), the a/d result lower-order byte register (adrl;20h), the a/d result higher-order byte register (adrh;21h), the a/d control register (adcr;22h), the a/d
ht46r47 rev. 1.40 9 july 18, 2001 clock setting register (acsr;23h), i/o regis - ters (pa;12h, pb;14h, pd;18h) and i/o con - trol registers (pac;13h, pbc;15h, pdc;19h). the remaining space before the 40h is re - served for future expanded usage and reading these locations will get "00h". the general purpose data memory, addressed from 40h to 7fh, is used for data and control information under instruction commands. all of the data memory areas can handle arith - metic, logic, increment, decrement and rotate operations directly. except for some dedicated bits, each bit in the data memory can be set and reset by "set [m].i" and "clr [m].i". they are also indirectly accessible through memory pointer register (mp;01h). indirect addressing register location 00h is an indirect addressing register that is not physically implemented. any read/write operation of [00h] accesses data mem - ory pointed to by mp (01h). reading location 00h itself indirectly will return the result 00h. writ - ing indirectly results in no operation. the memory pointer register mp (01h) is a 7-bit register. the bit 7 of mp is undefined and reading will return the result  1  . any writing operation to mp will only transfer the lower 7-bit data to mp. accumulator the accumulator is closely related to alu oper - ations. it is also mapped to location 05h of the data memory and can carry out immediate data operations. the data movement between two data memory locations must pass through the accumulator. arithmetic and logic unit  alu this circuit performs 8-bit arithmetic and logic operations. the alu provides the following func- tions:  arithmetic operations (add, adc, sub, sbc, daa)  logic operations (and, or, xor, cpl)  rotation (rl, rr, rlc, rrc)  increment and decrement (inc, dec)  branch decision (sz, snz, siz, sdz ....) the alu not only saves the results of a data op - eration but also changes the status register. status register  status this 8-bit register (0ah) contains the zero flag (z), carry flag (c), auxiliary carry flag (ac), overflow flag (ov), power down flag (pd), and watchdog time-out flag (to). it also records the  /#%0&' ,"/)$#    ? ? ? ? ? ?  ?  ? ? ?  ?  ?  ?  ?  ? ? ? ? ? ? ? ?  ?  ? ? ?  ?  ?  ?  ?  ? ? -20"#%. 22"#$$0-* #*0$.#"       ? 
                ?   b - , $ # 2  #&2&$cc ? ? ? ? ? ? 4 #-#"&' ,"/)$#    9  1.#$: ? ? ram mapping
ht46r47 rev. 1.40 10 july 18, 2001 status information and controls the operation sequence. with the exception of the to and pd flags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pd flag. in addition opera - tions related to the status register may give different results from those intended. the to flag can be affected only by system power-up, a wdt time-out or executing the "clr wdt" or "halt" instruction. the pd flag can be affected only by executing the "halt" or "clr wdt" instruction or a sys - tem power-up. the z, ov, ac and c flags generally reflect the status of the latest operations. in addition, on entering the interrupt sequence or executing the subroutine call, the status reg - ister will not be pushed onto the stack automat - ically. if the contents of the status are important and if the subroutine can corrupt the status register, precautions must be taken to save it properly. interrupt the device provides an external interrupt, in- ternal timer/event counter interrupt and a/d converter interrupts. the interrupt control register (intc;0bh) contains the interrupt control bits to set the enable/disable and the in - terrupt request flags. once an interrupt subroutine is serviced, all the other interrupts will be blocked (by clearing the emi bit). this scheme may prevent any fur - ther interrupt nesting. other interrupt re - quests may happen during this interval but only the interrupt request flag is recorded. if a certain interrupt requires servicing within the service routine, the emi bit and the correspond - ing bit of intc may be set to allow interrupt nesting. if the stack is full, the interrupt request will not be acknowledged, even if the related in - terrupt is enabled, until the sp is decremented. if immediate service is desired, the stack must be prevented from becoming full. all these kinds of interrupts have a wake-up ca - pability. as an interrupt is serviced, a control transfer occurs by pushing the program counter onto the stack, followed by a branch to a sub - routine at specified location in the program memory. only the program counter is pushed onto the stack. if the contents of the register or status register (status) are altered by the in- terrupt service program which corrupts the de- labels bits function c 0 c is set if the operation results in a carry during an addition operation or if a bor- row does not take place during a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. ac 1 ac is set if the operation results in a carry out of the low nibbles in addition or no borrow from the high nibble into the low nibble in subtraction; otherwise ac is cleared. z 2 z is set if the result of an arithmetic or logic operation is zero; otherwise z is cleared. ov 3 ov is set if the operation results in a carry into the highest-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. pd 4 pd is cleared by system power-up or executing the "clr wdt" instruction. pd is set by executing the "halt" instruction. to 5 to is cleared by system power-up or executing the "clr wdt" or "halt" in - struction. to is set by a wdt time-out.  6, 7 unused bit, read as "0" status register
ht46r47 rev. 1.40 11 july 18, 2001 sired control sequence, the contents should be saved in advance. external interrupts are triggered by a high to low transition of int and the related interrupt request flag (eif; bit 4 of intc) will be set. when the interrupt is enabled, the stack is not full and the external interrupt is active, a sub - routine call to location 04h will occur. the in - terrupt request flag (eif) and emi bits will be cleared to disable other interrupts. the internal timer/event counter interrupt is initialized by setting the timer/event counter interrupt request flag (tf; bit 5 of intc), caused by a timer overflow. when the interrupt is enabled, the stack is not full and the tf bit is set, a subroutine call to location 08h will occur. the related interrupt request flag (tf) will be reset and the emi bit cleared to disable further interrupts. the a/d converter interrupt is initialized by setting the a/d converter request flag (adf; bit 6 of intc), caused by an end of a/d conversion. when the interrupt is enabled, the stack is not full and the adf is set, a subroutine call to loca - tion 0ch will occur. the related interrupt re - quest flag (adf) will be reset and the emi bit cleared to disable further interrupts. during the execution of an interrupt subroutine, other interrupt acknowledgments are held until the "reti" instruction is executed or the emi bit and the related interrupt control bit are set to 1 (of course, if the stack is not full). to return from the interrupt subroutine, "ret" or "reti" may be invoked. reti will set the emi bit to en - able an interrupt service, but ret will not. interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding interrupts are en - abled. in the case of simultaneous requests the following table shows the priority that is ap - plied. these can be masked by resetting the emi bit. no. interrupt source priority vector a external interrupt 1 04h b timer/event counter overflow 2 08h c a/d converter interrupt 3 0ch the timer/event counter interrupt request flag (tf), external interrupt request flag (eif), a/d register bit no. label function intc (0bh) 0 emi controls the master (global) interrupt (1= enabled; 0= disabled) 1 eei controls the external interrupt (1= enabled; 0= disabled) 2 eti controls the timer/event counter interrupt (1= enabled; 0= disabled) 3 eadi controls the a/d converter interrupt (1= enabled; 0= disabled) 4 eif external interrupt request flag (1= active; 0= inactive) 5tf internal timer/event counter request flag (1= active; 0= inactive) 6 adf a/d converter request flag (1= active; 0= inactive) 7  unused bit, read as "0" intc register
ht46r47 rev. 1.40 12 july 18, 2001 converter request flag (adf), enable timer/event counter bit (eti), enable external interrupt bit (eei), enable a/d converter inter - rupt bit (eadi) and enable master interrupt bit (emi) constitute an interrupt control register (intc) which is located at 0bh in the data memory. emi, eei, eti, eadi are used to con - trol the enabling/disabling of interrupts. these bits prevent the requested interrupt from being serviced. once the interrupt request flags (tf, eif, adf) are set, they will remain in the intc register until the interrupts are serviced or cleared by a software instruction. it is recommended that a program does not use the "call subroutine" within the inter - rupt subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and enabling the interrupt is not well con trolled, the original control sequence will be damaged once the "call" operates in the in - terrupt subroutine. oscillator configuration there are two oscillator circuits in the microcontroller. both are designed for system clocks, namely the rc oscillator and the crystal oscillator, which are determined by the rom code option. no matter what oscillator type is selected, the signal provides the system clock. the halt mode stops the system oscillator and ignores an external signal to conserve power. if an rc oscillator is used, an external resistor between osc1 and vss is required and the re - sistance must range from 30k  to 750k  . the system clock, divided by 4, is available on osc2, which can be used to synchronize exter - nal logic. the rc oscillator provides the most cost effective solution. however, the frequency of oscillation may vary with vdd, tempera - tures and the chip itself due to process varia - tions. it is, therefore, not suitable for timing sensitive operations where an accurate oscilla - tor frequency is desired. if the crystal oscillator is used, a crystal across osc1 and osc2 is needed to provide the feed - back and phase shift required for the oscillator, and no other external components are required. instead of a crystal, a resonator can also be con - nected between osc1 and osc2 to get a fre - quency reference, but two external capacitors in osc1 and osc2 are required (if the oscillat - ing frequency is less than 1mhz). the wdt oscillator is a free running on-chip rc oscillator, and no external components are re - quired. even if the system enters the power down mode, the system clock is stopped, but the wdt oscillator still works with a period of approxi- mately 72  s/5v. the wdt oscillator can be dis- abled by rom code option to conserve power. watchdog timer  wdt the clock source of wdt is implemented by a dedicated rc oscillator (wdt oscillator) or in- struction clock (system clock divided by 4), de- cided by rom code option. this timer is designed to prevent a software malfunction or sequence from jumping to an unknown location with unpredictable results. the watchdog  "1$.&' $%0''&.)"    $%0''&.)"  
   /#- "&0-  (    system oscillator  1$.#+  ')%= 7>0. ),-.#"     "#$%&'#" 7>0. ),-.#"        )2# /.0)- #'#%.      0+ #7),. ( $ ( $  5 ( $    watchdog timer
ht46r47 rev. 1.40 13 july 18, 2001 timer can be disabled by a rom code option. if the watchdog timer is disabled, all the execu - tions related to the wdt result in no operation. once the internal oscillator (rc oscillator with a period of 72  s/5v normally) is selected, it is first divided by 256 (8-stage) to get the nominal time-out period of approximately 18.6ms/5v. this time-out period may vary with tempera - tures, vdd and process variations. by invoking the wdt prescaler, longer time-out periods can be realized and the maximum time-out period is 2.3s/5v~4.7s/5v seconds. if the wdt oscilla - tor is disabled, the wdt clock may still come from the instruction clock and operate in the same manner except that in the halt state the wdt may stop counting and lose its protecting purpose. in this situation the logic can only be restarted by external logic. if the device operates in a noisy environment, us - ing the on-chip rc oscillator (wdt osc) is strongly recommended, since the halt will stop the system clock. the wdt overflow under normal operation will initialize  chip reset  and set the status bit  to  . but in the halt mode, the overflow will initialize a  warm reset  , and only the pc and sp are reset to zero. to clear the contents of wdt, three methods are adopted; external re- set (a low level to res ), software instruction and a "halt" instruction. the software in- struction include  clr wdt  and the other set  clr wdt1  and  clr wdt2  . of these two types of instruction, only one can be active de- pending on the rom code option  clr wdt times selection option  .ifthe  clr wdt  is se- lected (i.e. clrwdt times equal one), any exe- cution of the  clr wdt  instruction will clear the wdt. in the case that  clr wdt1  and  clr wdt2  are chosen (i.e. clrwdt times equal two), these two instructions must be exe - cuted to clear the wdt; otherwise, the wdt may reset the chip as a result of time-out. power down operation  halt the halt mode is initialized by the  halt  instruction and results in the following...  the system oscillator will be turned off but the wdt oscillator keeps running (if the wdt oscillator is selected).  the contents of the on chip ram and regis - ters remain unchanged.  wdt will be cleared and recounted again (if the wdt clock is from the wdt oscillator).  all of the i/o ports maintain their original sta - tus.  the pd flag is set and the to flag is cleared. the system can leave the halt mode by means of an external reset, an interrupt, an external falling edge signal on port a or a wdt overflow. an external reset causes a device initialization and the wdt overflow performs a  warm re - set  . after the to and pd flags are examined, the reason for chip reset can be determined. the pd flag is cleared by system power-up or executing the  clr wdt  instruction and is set when executing the  halt  instruction. the to flag is set if the wdt time-out occurs, and causes a wake-up that only resets the pc and sp; the others keep their original status. the port a wake-up and interrupt methods can be considered as a continuation of normal exe - cution. each bit in port a can be independently selected to wake up the device by the rom code option. awakening from an i/o port stimulus, the program will resume execution of the next instruction. if it is awakening from an inter- rupt, two sequences may happen. if the related interrupt is disabled or the interrupt is enabled but the stack is full, the program will resume execution at the next instruction. if the inter- rupt is enabled and the stack is not full, the reg- ular interrupt response takes place. if an interrupt request flag is set to  1  before enter- ing the halt mode, the wake-up function of the related interrupt will be disabled. once a wake-up event occurs, it takes 1024 t sys (sys - tem clock period) to resume normal operation. in other words, a dummy period will be inserted after wake-up. if the wake-up results from an interrupt acknowledgment, the actual inter - rupt subroutine execution will be delayed by one or more cycles. if the wake-up results in the next instruction execution, this will be executed immediately after the dummy period is fin - ished. to minimize power consumption, all the i/o pins should be carefully managed before enter - ing the halt status.
ht46r47 rev. 1.40 14 july 18, 2001 reset there are three ways in which a reset can occur:  res reset during normal operation  res reset during halt  wdt time-out reset during normal operation the wdt time-out during halt is different from other chip reset conditions, since it can perform a  warm reset  that resets only the pc and sp, leaving the other circuits in their origi - nal state. some registers remain unchanged during other reset conditions. most registers are reset to the  initial condition  when the re - set conditions are met. by examining the pd and to flags, the program can distinguish be - tween different  chip resets  . to pd reset conditions 0 0 res reset during power-up u u res reset during normal operation 0 1 res wake-up halt 1u wdt time-out during normal opera - tion 1 1 wdt wake-up halt note:  u  means  unchanged  to guarantee that the system oscillator is started and stabilized, the sst (system start-up timer) provides an extra-delay of 1024 system clock pulses when the system reset (power-up, wdt time-out or res reset) or the system awakes from the halt state. when a system reset occurs, the sst delay is added during the reset period. any wake-up from halt will enable the sst delay. the functional unit chip reset status are shown below. pc 000h interrupt disable wdt clear. after master reset, wdt begins counting timer/event counter off input/output ports input mode sp points to the top of the stack .      0+ #7),.  30/ #$#. reset timing chart    reset circuit  &"+  #$#.  ?  )'2 #$#.   1$.#+  #$#.  7>0. 0//'#  ),-.#"  reset configuration
ht46r47 rev. 1.40 15 july 18, 2001 the registers
states are summarized in the following table. register reset (power on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out (halt)* tmr xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmrc 00-0 1000 00-0 1000 00-0 1000 00-0 1000 uu-u uuuu program counter 000h 000h 000h 000h 000h mp -xxx xxxx -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblh --xx xxxx --uu uuuu --uu uuuu --uu uuuu --uu uuuu status --00 xxxx --1u uuuu --uu uuuu --01 uuuu --11 uuuu intc -000 0000 -000 0000 -000 0000 -000 0000 -uuu uuuu pa 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pac 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pb ---- 1111 ---- 1111 ---- 1111 ---- 1111 ---- uuuu pbc ---- 1111 ---- 1111 ---- 1111 ---- 1111 ---- uuuu pd ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u pdc ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u pwm xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu adrl x--- ---- x--- ---- x--- ---- x--- ---- u--- ---- adrh xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu adcr 0100 0000 0100 0000 0100 0000 0100 0000 uuuu uuuu acsr 1--- --00 1--- --00 1--- --00 1--- --00 u---- --uu note:  *  stands for  warm reset   u  stands for  unchanged   x  stands for  unknown 
ht46r47 rev. 1.40 16 july 18, 2001 timer/event counter a timer/event counter (tmr) is implemented in the microcontroller. the timer/event counter contains an 8-bit programmable count-up coun - ter and the clock may come from an external source or the system clock. using the internal system clock, there is only one reference time-base. the internal clock source comes from f sys . the external clock in - put allows the user to count external events, measure time intervals or pulse widths, or to generate an accurate time base. there are 2 registers related to the timer/event counter; tmr ([0dh]), tmrc ([0eh]). two phys - ical registers are mapped to tmr location; writ - ing tmr makes the starting value be placed in the timer/event counter preload register and reading tmr gets the contents of the timer/event counter. the tmrc is a timer/event counter con - trol register, which defines some options. label (tmrc) bits function psc0~psc2 0~2 to define the prescaler stages, psc2, psc1, psc0= 000: f int =f sys 001: f int =f sys /2 010: f int =f sys /4 011: f int =f sys /8 100: f int =f sys /16 101: f int =f sys /32 110: f int =f sys /64 111: f int =f sys /128 te 3 to define the tmr active edge of timer/event counter (0=active on low to high; 1=active on high to low) ton 4 to enable/disable timer counting (0=disabled; 1=enabled)  5 unused bit, read as  0  tm0 tm1 6 7 to define the operating mode 01=event count mode (external clock) 10=timer mode (internal clock) 11=pulse width measurement mode 00=unused tmrc register            
 ,'$# 02.3  #&$,"#+ #-.  )2# )-.")' 0+ #" 8#-. ),-.#"  "#')&2 #*0$.#" 0+ #" 8#-.  ),-.#" &.&,$  #')&2 8#"(')a .) -.#"",/.   7$.&*#/"#$%&'#" 7   (  (
 5 9 <  :% ) + / & "#   .)    % 0"% , 0. timer/event counter
ht46r47 rev. 1.40 17 july 18, 2001 the tm0, tm1 bits define the operating mode. the event count mode is used to count external events, which means the clock source comes from an external (tmr) pin. the timer mode functions as a normal timer with the clock source coming from the f int clock. the pulse width measurement mode can be used to count the high or low level du - ration of the external signal (tmr). the counting is based on the f int . in the event count or timer mode, once the timer/event counter starts counting, it will count from the current contents in the timer/event counter to ffh. once overflow occurs, the coun - ter is reloaded from the timer/event counter preload register and generates the interrupt re - quest flag (tf; bit 5 of intc) at the same time. in the pulse width measurement mode with the ton and te bits equal to one, once the tmr has received a transient from low to high (or high to low if the te bits is  0  ) it will start counting until the tmr returns to the original level and resets the ton. the measured result will remain in the timer/event counter even if the activated transient occurs again. in other words, only one cycle measurement can be done. until setting the ton, the cycle measure- ment will function again as long as it receives further transient pulse. note that, in this oper- ating mode, the timer/event counter starts counting not according to the logic level but ac- cording to the transient edges. in the case of counter overflows, the counter is reloaded from the timer/event counter preload register and is- sues the interrupt request just like the other two modes. to enable the counting operation, the timer on bit (ton; bit 4 of tmrc) should be set to 1. in the pulse width measurement mode, the ton will be cleared automatically af - ter the measurement cycle is completed. but in the other two modes the ton can only be reset by instructions. the overflow of the timer/event counter is one of the wake-up sources. no mat - ter what the operation mode is, writing a 0 to eti can disable the interrupt service. in the case of timer/event counter off condi - tion, writing data to the timer/event counter preload register will also reload that data to the timer/event counter. but if the timer/event counter is turned on, data written to it will only be kept in the timer/event counter preload reg - ister. the timer/event counter will still operate until overflow occurs. when the timer/event counter (reading tmr) is read, the clock will be blocked to avoid errors. as clock blocking may re - sults in a counting error, this must be taken into consideration by the programmer. the bit0~bit2 of the tmrc can be used to de - fine the pre-scaling stages of the internal clock sources of timer/event counter. the definitions are as shown. the overflow signal of timer/event counter can be used to generate the pfd signal. the timer prescaler is also used as the pwm counter. input/output ports there are 13 bidirectional input/output lines in the microcontroller, labeled as pa, pb and pd, which are mapped to the data memory of [12h], [14h] and [18h] respectively. all of these i/o ports can be used for input and output opera - tions. for input operation, these ports are non-latching, that is, the inputs must be ready at the t2 rising edge of instruction  mov a,[m]  (m=12h, 14h or 18h). for output operation, all the data is latched and remains unchanged until the output latch is rewritten. each i/o line has its own control register (pac, pbc, pdc) to control the input/output configu- ration. with this control register, cmos output or schmitt trigger input with or without pull-high resistor structures can be reconfig- ured dynamically (i.e. on-the-fly) under soft- ware control. to function as an input, the corresponding latch of the control register must write  1  . the input source also depends on the control register. if the control register bit is  1  , the input will read the pad state. if the control register bit is  0  , the contents of the latches will move to the internal bus. the latter is pos - sible in the  read-modify-write  instruction. for output function, cmos is the only configu - ration. these control registers are mapped to locations 13h, 15h and 19h. after a chip reset, these input/output lines re - main at high levels or floating state (dependent
ht46r47 rev. 1.40 18 july 18, 2001 on pull-high options). each bit of these in - put/output latches can be set or cleared by  set [m].i  and  clr [m].i  (m=12h, 14h or 18h) in - structions. some instructions first input data and then fol - low the output operations. for example,  set [m].i  ,  clr [m].i  ,  cpl [m]  ,  cpla [m]  read the entire port states into the cpu, execute the defined operations (bit-operation), and then write the results back to the latches or the accu - mulator. each line of port a has the capability of wak - ing-up the device. the highest 4-bit of port b and 7 bits of port d are not physically implemented; on reading them a  0  is returned whereas writ - ing then results in a no-operation. see applica - tion note. each i/o line has a pull-high option. once the pull-high option is selected, the i/o line has a pull-high resistor, otherwise, there
s none. take note that a non-pull-high i/o line operat - ing in input mode will cause a floating state. the pa3 is pin-shared with the pfd signal. if the pfd option is selected, the output signal in output mode of pa3 will be the pfd signal gen- erated by timer/event counter overflow signal. the input mode always remaining its original functions. once the pfd option is selected, the pfd output signal is controlled by pa3 data register only. writing  1  to pa3 data register will enable the pfd output function and writ - ing  0  will force the pa3 to remain at  0  . the i/o functions of pa3 are shown below. i/o mode i/p (normal) o/p (normal) i/p (pfd) o/p (pfd) pa3 logical input logical output logical input pfd (timer on) note: the pfd frequency is the timer/event counter overflow frequency divided by 2. the pa5 and pa4 are pin-shared with int and tmr pins respectively. the pb can also be used as a/d converter in - puts. the a/d function will be described later. there is a pwm function shared with pd0. if the pwm function is enabled, the pwm signal will appear on pd0 (if pd0 is operating in out - put mode). the i/o functions of pd0 are as shown.         
9   : 5    ()" -'1
 () "    - '1  1$.#+  &=#7,/ 9  )-'1:  #&2 &.& #*0$.#"   9   ) "   :  d ! d   d ! d   )-.")' 0.  &.&,$  "0.# )-.")' #*0$.#"  30/ #$#.  #&2 )-.")' #*0$.#"  "0.# &.& #*0$.#" &.&0. 5    
  6   
5  
   input/output ports
ht46r47 rev. 1.40 19 july 18, 2001 i/o mode i/p (normal) o/p (normal) i/p (pwm) o/p (pwm) pd0 logical input logical output logical input pwm it is recommended that unused or not bonded out i/o lines should be set as output pins by software instruction to avoid consuming power under input floating state. pwm the microcontroller provides 1 channel (6+2) bits pwm output shared with pd0. the pwm channel has its data register denoted as pwm (1ah). the frequency source of the pwm coun - ter comes from f sys . the pwm register is an eight bits register. the waveforms of pwm out - put are as shown. once the pd0 is selected as the pwm output and the output function of pd0 is enabled (pdc.0=  0  ), writing 1 to pd0 data register will enable the pwm output func - tion and writing  0  will force the pd0 to stay at  0  . a pwm cycle is divided into four modulation cy - cles (modulation cycle 0~modulation cycle 3). each modulation cycle has 64 pwm input clock period. in a (6+2) bit pwm function, the con- tents of the pwm register is divided into two groups. group 1 of the pwm register is denoted by dc which is the value of pwm.7~pwm.2. the group 2 is denoted by ac which is the value of pwm.1~pwm.0. in a pwm cycle, the duty cycle of each modula - tion cycle is shown in the table. parameter ac (0~3) duty cycle modulation cycle i (i=0~3) i ht46r47 rev. 1.40 20 july 18, 2001 label (adcr) bits function acs0 acs1 acs2 0 1 2 acs2, acs1, acs0: select a/d channel 0, 0, 0: an0 0, 0, 1: an1 0, 1, 0: an2 0, 1, 1: an3 1, x, x: undefined, cannot be used pcr0 pcr1 pcr2 3 4 5 pcr2, pcr1, pcr0: pb3~pb0 configurations 0, 0, 0: pb3 pb2 pb1 pb0 (the adc circuit is power off to reduce power consumption.) 0, 0, 1: pb3 pb2 pb1 an0 0, 1, 0: pb3 pb2 an1 an0 0, 1, 1: pb3 an2 an1 an0 1, x, x: an3 an2 an1 an0 eoc 6 end of a/d conversion flag. (0: end of a/d conversion) start 7 start the a/d conversion 0 1 0: start 0 1: reset a/d converter and set eoc to  1  bits function adcs0 adcs1 0 1 adcs1, adcs0: select the a/d converter clock source. 0, 0: f sys /2 0, 1: f sys /8 1, 0: f sys /32 1, 1: undefined, cannot be used.  2~6 unused bit, read as  0  . test 7 for internal test only. version control bit and the end of a/d conver - sion flag. if the users want to start an a/d conversion, define pb configuration, select the converted analog channel, and give start bit a raising edge and a falling edge (0 1 0). at the end of a/d conversion, the eoc bit is cleared and an a/d converter interrupt occurs (if the a/d converter interrupt is enabled). the acsr is a/d clock setting register, which is used to select the a/d clock source. the a/d converter control register is used to control the a/d converter. the bit2~bit0 of the adcr are used to select an analog input chan - nel. there are a total of four channels to select. the bit5~bit3 of the adcr are used to set pb configurations. pb can be an analog input or as digital i/o line decided by these 3 bits. once a pb line is selected as an analog input, the i/o functions and pull-high resistor of this i/o line are disabled, and the a/d converter circuit is power on. the eoc bit (bit6 of the adcr) is end of a/d conversion flag. check this bit to know when a/d conversion is completed. the start bit of the adcr is used to begin the conversion of a/d converter. give start bit a raising edge and falling edge that means the a/d conversion has started. in order to ensure the a/d conversion is completed, the start should stay at  0  until the eoc is cleared to  0  (end of a/d conversion). the bit 7 of the acsr is used for testing pur - pose only. it can not be used for the users. the bit1 and bit0 of the acsr are used to select a/d clock sources.
ht46r47 rev. 1.40 21 july 18, 2001 when the a/d conversion is completed, the a/d interrupt request flag is set. the eoc bit is set to  1  when the start bit is set from  0  to  1  . register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adrl d0  adrh d8 d7 d6 d5 d4 d3 d2 d1 * d0~d8 is a/d conversion result data bit lsb~msb. low voltage reset  lvr the microcontroller provides low voltage reset circuit in order to monitor the supply voltage of the device. if the supply voltage of the device is within the range 0.9v~3.3v, such as changing a battery, the lvr will automatically reset the device internally. the lvr includes the following specifications:  the low voltage (0.9v~3.3v) has to remain in their original state to exceed 1ms. if the low voltage state does not exceed 1ms, the lvr will ignore it and do not perform a reset func - tion.  the lvr uses the  or  function with the exter - nal res signal to perform chip reset. the relationship between v dd and v lvr is shown below. note: v opr is the voltage range for proper chip operation at 4mhz system clock.     h      hh       5 5 )a#" - #$#.  .& ".) (  %)-8#"$0)- #$#. %)-8#".#"  .& ".) (  %)-8#"$0)- #$#. %)-8#".#"  -2)(  %)-8#".#"  -2)(  %)-8#".#" b #(0-#  %)-(0*,"&.0)- b #'#%.&-&')*%3&--#' hhh b # '# % .   % ') % = 9 ;&+ /'#b%3&--#'6
6   (   : b ''  '0-#0$20*0.&'0-/,.  b  % ) - 8 # ".# "0$ / ) a # ") (( .)"#2,%#/)a #"%)-$,+ /.0)- h   chc  %)-8#".0-*.0+ #0$   chhc    + #&-$2)-i.%&"# chhhc   %')%=+ ,$.>#(   6(   6(   
).#b j j j j       j
ht46r47 rev. 1.40 22 july 18, 2001 rom code option the following table shows all kinds of rom code option in the microcontroller. all of the rom code options must be defined to ensure proper system functioning. items option 1 wdt clock source: wdtosc/f tid 2 wdt enable/disable: enable/disable 3 clrwdt instruction(s) : one/two clear wdt instruction(s) 4 system oscillator: rc/crystal 5 pull-high resistors (pa, pb, pd): none/pull-high 6 pwm enable/disable 7 pa0~pa7 wake-up: disable/enable 8 pfd enable/disable 9 lock: unlock/lock 10 low voltage reset selection: enable or disable lvr function.   j   j   #$#. 0*-&' #$#. h h
) "+ & ' / # "& .0) -  # $ # .    #.#%. )'.&*# low voltage reset note: *1:to make sure that the system oscillator has stabilized, the sst provides an extra delay of 1024 system clock pulses before entering the normal operation. *2:since the low voltage has to maintain in its original state and exceed 1ms, therefore 1ms delay enter the reset mode.
application circuits battery charger for 1-set battery charger applications ht46r47 rev. 1.40 23 july 18, 2001       j   =     6    
  6  
 
 
  >&. (  . 
      0"%,0.  ##>#')a
).#b 3#"#$0$.&-%#&-2%&/&%0.&-%#()""#$#.%0"%,0.$3),'2>#2#$0*-#2 .)#-$,"#.3&..3#   0$$.&>'#&-2"#+ &0-$0-&8&'02"&-*#) (.3 # )/#"&.0-*8)'.&*#>#()"#>"0-*0-*   .)30*3j  <  > & .b j  9
0 2 6
0 ? :) " j  9 0: j  
battery charger for 2-set battery charger applications ht46r47 rev. 1.40 24 july 18, 2001    j   =      
 ( 
        
  ?  ?  >&.  >&.      0"%,0.  ##>#')a   (      $1$.#+ )$%0''&.)" =  k  k =   "1$.&'$1$.#+ )$%0''&.)"  g g/60((  k ? @ .3#"a 0$#6 g g      > & . 6 > & . b j  9
0 2 6
0 ? :) " j  9 0: < 
 
   j    /
instruction set summary mnemonic description instruction cycle flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to register with carry subtract immediate data from acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry and result in data memory decimal adjust acc for addition with result in data memory 1 1 (1) 1 1 1 (1) 1 1 1 (1) 1 1(1) 1 (1) z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov z,c,ac,ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] and data memory to acc or data memory to acc exclusive-or data memory to acc and acc to data memory or acc to data memory exclusive-or acc to data memory and immediate data to acc or immediate data to acc exclusive-or immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 (1) 1 (1) 1 (1) 1 1 1 1 (1) 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 (1) 1 1 (1) z z z z ht46r47 rev. 1.40 25 july 18, 2001
mnemonic description instruction cycle flag affected rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 (1) 1 1 (1) 1 1 (1) 1 1 (1) none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 (1) 1 none none none bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 (1) 1 (1) none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 (2) 1 (2) 1 (2) 1 (2) 1 (3) 1 (3) 1 (2) 1 (2) 2 2 2 2 none none none none none none none none none none none none none ht46r47 rev. 1.40 26 july 18, 2001
mnemonic description instruction cycle flag affected table read tabrdc [m] tabrdl [m] read rom code (current page) to data memory and tblh read rom code (last page) to data memory and tblh 2 (1) 2 (1) none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 (1) 1 (1) 1 1 1 1 (1) 1 1 none none none to,pd to (4) ,pd (4) to (4) ,pd (4) none none to,pd note: x: 8 bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address  : flag is affected  : flag is not affected (1) : if a loading to the pcl register occurs, the execution cycle of instructions will be delayed for one more cycle (four system clocks). (2) : if a skipping to next instruction occurs, the execution cycle of instructions will be delayed one more cycle (four system clocks). otherwise the original instruction cycle is unchanged. (3) : (1) and (2) (4) : the flags may be affected by the execution status. if the watchdog timer is cleared by executing the clr wdt1 or clr wdt2 instruction, the to is set and the pd is cleared. otherwise the to and pd flags remain unchanged. ht46r47 rev. 1.40 27 july 18, 2001
instruction definition adc a,[m] add data memory and carry to the accumulator. description the contents of the specified data memory, accumulator and the carry flag are added simultaneously, leaving the result in the accumulator. operation acc  acc+[m]+c affected flag(s) tc2 tc1 to pd ov z ac c  adcm a,[m] add the accumulator and carry to data memory. description the contents of the specified data memory, accumulator and the carry flag are added simultaneously, leaving the result in the specified data memory. operation [m]  acc+[m]+c affected flag(s) tc2 tc1 to pd ov z ac c  add a,[m] add data memory to the accumulator. description the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc  acc+[m] affected flag(s) tc2 tc1 to pd ov z ac c  add a,x add immediate data to the accumulator. description the contents of the accumulator and the specified data are added, leaving the result in the accumulator. operation acc  acc+x affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 28 july 18, 2001
addm a,[m] add the accumulator to the data memory. description the contents of the specified data memory and the accumulator are added. the result is stored in the data memory. operation [m]  acc+[m] affected flag(s) tc2 tc1 to pd ov z ac c  and a,[m] logical and accumulator with data memory. description data in the accumulator and the specified data memory perform a bitwise logical_and operation. the result is stored in the accumulator. operation acc  acc "and" [m] affected flag(s) tc2 tc1 to pd ov z ac c  and a,x logical and immediate data to the accumulator. description data in the accumulator and the specified data perform a bitwise logi - cal_and operation. the result is stored in the accumulator. operation acc  acc "and" x affected flag(s) tc2 tc1 to pd ov z ac c  andm a,[m] logical and data memory with the accumulator. description data in the specified data memory and the accumulator perform a bitwise logical_and operation. the result is stored in the data memory. operation [m]  acc "and" [m] affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 29 july 18, 2001
call addr subroutine call. description the instruction unconditionally calls a subroutine located at the indicated address. the program counter increments once to obtain the address of the next instruction, and pushes this onto the stack. the indicated address is then loaded. program execution continues with the instruction at this ad - dress. operation stack  pc+1 pc  addr affected flag(s) tc2 tc1 to pd ov z ac c   clr [m] clear data memory. description the contents of the specified data memory are cleared to 0. operation [m]  00h affected flag(s) tc2 tc1 to pd ov z ac c   clr [m].i clear bit of data memory. description the bit i of the specified data memory is cleared to 0. operation [m].i  0 affected flag(s) tc2 tc1 to pd ov z ac c   clr wdt clear watchdog timer. description the wdt and the wdt prescaler are cleared (re-counting from 0). the power down bit (pd) and time-out bit (to) are cleared. operation wdt and wdt prescaler  00h pd and to  0 affected flag(s) tc2 tc1 to pd ov z ac c  00  ht46r47 rev. 1.40 30 july 18, 2001
clr wdt1 preclear watchdog timer. description the to, pd flags, wdt and the wdt prescaler has cleared (re-counting from 0), if the other preclear wdt instruction has been executed. only exe - cution of this instruction without the other preclear instruction just sets the indicated flag which implies this instruction has been executed and the to and pd flags remain unchanged. operation wdt and wdt prescaler  00h* pd and to  0* affected flag(s) tc2 tc1 to pd ov z ac c  0* 0*  clr wdt2 preclear watchdog timer. description the to, pd flags, wdt and the wdt prescaler are cleared (re-counting from 0), if the other preclear wdt instruction has been executed. only exe - cution of this instruction without the other preclear instruction, sets the in - dicated flag which implies this instruction has been executed and the to and pd flags remain unchanged. operation wdt and wdt prescaler  00h* pd and to  0* affected flag(s) tc2 tc1 to pd ov z ac c  0* 0*  cpl [m] complement data memory. description each bit of the specified data memory is logically complemented (1's comple- ment). bits which previously contained a 1 are changed to 0 and vice-versa. operation [m]  [m ] affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 31 july 18, 2001
cpla [m] complement data memory and place result in the accumulator. description each bit of the specified data memory is logically complemented (1's comple - ment). bits which previously contained a 1 are changed to 0 and vice-versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc  [m ] affected flag(s) tc2 tc1 to pd ov z ac c  daa [m] decimal-adjust accumulator for addition. description the accumulator value is adjusted to the bcd (binary coded decimal) code. the accumulator is divided into two nibbles. each nibble is adjusted to the bcd code and an internal carry (ac1) will be done if the low nibble of the ac - cumulator is greater than 9. the bcd adjustment is done by adding 6 to the original value if the original value is greater than 9 or a carry (ac or c) is set; otherwise the original value remains unchanged. the result is stored in the data memory and only the carry flag (c) may be affected. operation if acc.3~acc.0 >9 or ac=1 then [m].3~[m].0  (acc.3~acc.0)+6, ac1=ac else [m].3~[m].0)  (acc.3~acc.0), ac1=0 and if acc.7~acc.4+ac1 >9 or c=1 then [m].7~[m].4  acc.7~acc.4+6+ac1,c=1 else [m].7~[m].4  acc.7~acc.4+ac1,c=c affected flag(s) tc2 tc1 to pd ov z ac c    dec [m] decrement data memory. description data in the specified data memory is decremented by 1. operation [m]  [m]  1 affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 32 july 18, 2001
deca [m] decrement data memory and place result in the accumulator. description data in the specified data memory is decremented by 1, leaving the result in the accumulator. the contents of the data memory remain unchanged. operation acc  [m]  1 affected flag(s) tc2 tc1 to pd ov z ac c  halt enter power down mode. description this instruction stops program execution and turns off the system clock. the contents of the ram and registers are retained. the wdt and prescaler are cleared. the power down bit (pd) is set and the wdt time-out bit (to) is cleared. operation pc  pc+1 pd  1 to  0 affected flag(s) tc2 tc1 to pd ov z ac c  01  inc [m] increment data memory. description data in the specified data memory is incremented by 1. operation [m]  [m]+1 affected flag(s) tc2 tc1 to pd ov z ac c  inca [m] increment data memory and place result in the accumulator. description data in the specified data memory is incremented by 1, leaving the result in the accumulator. the contents of the data memory remain unchanged. operation acc  [m]+1 affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 33 july 18, 2001
jmp addr directly jump. description bits of the program counter are replaced with the directly-specified address unconditionally, and control is passed to this destination. operation pc  addr affected flag(s) tc2 tc1 to pd ov z ac c   mov a,[m] move data memory to the accumulator. description the contents of the specified data memory are copied to the accumulator. operation acc  [m] affected flag(s) tc2 tc1 to pd ov z ac c   mov a,x move immediate data to the accumulator. description the 8-bit data specified by the code is loaded into the accumulator. operation acc  x affected flag(s) tc2 tc1 to pd ov z ac c   mov [m],a move the accumulator to data memory. description the contents of the accumulator are copied to the specified data memory (one of the data memory). operation [m]  acc affected flag(s) tc2 tc1 to pd ov z ac c   nop no operation. description no operation is performed. execution continues with the next instruction. operation pc  pc+1 affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 34 july 18, 2001
or a,[m] logical or accumulator with data memory. description data in the accumulator and the specified data memory (one of the data memory) perform a bitwise logical_or operation. the result is stored in the accumulator. operation acc  acc "or" [m] affected flag(s) tc2 tc1 to pd ov z ac c  or a,x logical or immediate data to the accumulator. description data in the accumulator and the specified data perform a bitwise logical_or operation. the result is stored in the accumulator. operation acc  acc "or" x affected flag(s) tc2 tc1 to pd ov z ac c  orm a,[m] logical or data memory with the accumulator. description data in the data memory (one of the data memory) and the accumulator per - form a bitwise logical_or operation. the result is stored in the data memory. operation [m]  acc "or" [m] affected flag(s) tc2 tc1 to pd ov z ac c  ret return from subroutine. description the program counter is restored from the stack. this i s a 2 cycle instruction. operation pc  stack affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 35 july 18, 2001
ret a,x return and place immediate data in the accumulator. description the program counter is restored from the stack and the accumulator loaded with the specified 8-bit immediate data. operation pc  stack acc  x affected flag(s) tc2 tc1 to pd ov z ac c   reti return from interrupt. description the program counter is restored from the stack, and interrupts are enabled by setting the emi bit. emi is the enable master (global) interrupt bit (bit 0; register intc). operation pc  stack emi  1 affected flag(s) tc2 tc1 to pd ov z ac c   rl [m] rotate data memory left. description the contents of the specified data memory are rotated 1 bit left with bit 7 ro - tated into bit 0. operation [m].(i+1)  [m].i; [m].i:bit i of the data memory (i=0~6) [m].0  [m].7 affected flag(s) tc2 tc1 to pd ov z ac c   rla [m] rotate data memory left and place result in the accumulator. description data in the specified data memory is rotated 1 bit left with bit 7 rotated into bit 0, leaving the rotated result in the accumulator. the contents of the data memory remain unchanged. operation acc.(i+1)  [m].i; [m].i:bit i of the data memory (i=0~6) acc.0  [m].7 affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 36 july 18, 2001
rlc [m] rotate data memory left through carry. description the contents of the specified data memory and the carry flag are rotated 1 bit left. bit 7 replaces the carry bit; the original carry flag is rotated into the bit 0 position. operation [m].(i+1)  [m].i; [m].i:bit i of the data memory (i=0~6) [m].0  c c  [m].7 affected flag(s) tc2 tc1 to pd ov z ac c    rlca [m] rotate left through carry and place result in the accumulator. description data in the specified data memory and the carry flag are rotated 1 bit left. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0 posi - tion. the rotated result is stored in the accumulator but the contents of the data memory remain unchanged. operation acc.(i+1)  [m].i; [m].i:bit i of the data memory (i=0~6) acc.0  c c  [m].7 affected flag(s) tc2 tc1 to pd ov z ac c    rr [m] rotate data memory right. description the contents of the specified data memory are rotated 1 bit right with bit 0 rotated to bit 7. operation [m].i  [m].(i+1); [m].i:bit i of the data memory (i=0~6) [m].7  [m].0 affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 37 july 18, 2001
rra [m] rotate right and place result in the accumulator. description data in the specified data memory is rotated 1 bit right with bit 0 rotated into bit 7, leaving the rotated result in the accumulator. the contents of the data memory remain unchanged. operation acc.(i)  [m].(i+1); [m].i:bit i of the data memory (i=0~6) acc.7  [m].0 affected flag(s) tc2 tc1 to pd ov z ac c   rrc [m] rotate data memory right through carry. description the contents of the specified data memory and the carry flag are together ro - tated 1 bit right. bit 0 replaces the carry bit; the original carry flag is rotated into the bit 7 position. operation [m].i  [m].(i+1); [m].i:bit i of the data memory (i=0~6) [m].7  c c  [m].0 affected flag(s) tc2 tc1 to pd ov z ac c    rrca [m] rotate right through carry and place result in the accumulator. description data of the specified data memory and the carry flag are rotated 1 bit right. bit 0 replaces the carry bit and the original carry flag is rotated into the bit 7 position. the rotated result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); [m].i:bit i of the data memory (i=0~6) acc.7  c c  [m].0 affected flag(s) tc2 tc1 to pd ov z ac c    ht46r47 rev. 1.40 38 july 18, 2001
sbc a,[m] subtract data memory and carry from the accumulator. description the contents of the specified data memory and the complement of the carry flag are subtracted from the accumulator, leaving the result in the accumula - tor. operation acc  acc+[m ]+c affected flag(s) tc2 tc1 to pd ov z ac c  sbcm a,[m] subtract data memory and carry from the accumulator. description the contents of the specified data memory and the complement of the carry flag are subtracted from the accumulator, leaving the result in the data memory. operation [m]  acc+[m ]+c affected flag(s) tc2 tc1 to pd ov z ac c  sdz [m] skip if decrement data memory is 0. description the contents of the specified data memory are decremented by 1. if the result is 0, the next instruction is skipped. if the result is 0, the following instruc - tion, fetched during the current instruction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if ([m]  1)=0, [m]  ([m]  1) affected flag(s) tc2 tc1 to pd ov z ac c   sdza [m] decrement data memory and place result in acc, skip if 0. description the contents of the specified data memory are decremented by 1. if the result is 0, the next instruction is skipped. the result is stored in the accumulator but the data memory remains unchanged. if the result is 0, the following in - struction, fetched during the current instruction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if ([m]  1)=0, acc  ([m]  1) affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 39 july 18, 2001
set [m] set data memory. description each bit of the specified data memory is set to 1. operation [m]  ffh affected flag(s) tc2 tc1 to pd ov z ac c   set [m].i set bit of data memory. description bit  i  of the specified data memory is set to 1. operation [m].i  1 affected flag(s) tc2 tc1 to pd ov z ac c   siz [m] skip if increment data memory is 0. description the contents of the specified data memory are incremented by 1. if the result is 0, the following instruction, fetched during the current instruction execu - tion, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if ([m]+1)=0, [m]  ([m]+1) affected flag(s) tc2 tc1 to pd ov z ac c   siza [m] increment data memory and place result in acc, skip if 0. description the contents of the specified data memory are incremented by 1. if the result is 0, the next instruction is skipped and the result is stored in the accumula- tor. the data memory remains unchanged. if the result is 0, the following in- struction, fetched during the current instruction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if ([m]+1)=0, acc  ([m]+1) affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 40 july 18, 2001
snz [m].i skip if bit  i  of the data memory is not 0. description if bit  i  of the specified data memory is not 0, the next instruction is skipped. if bit  i  of the data memory is not 0, the following instruction, fetched during the current instruction execution, is discarded and a dummy cycle is re - placed to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if [m].i  0 affected flag(s) tc2 tc1 to pd ov z ac c   sub a,[m] subtract data memory from the accumulator. description the specified data memory is subtracted from the contents of the accumula - tor, leaving the result in the accumulator. operation acc  acc+[m ]+1 affected flag(s) tc2 tc1 to pd ov z ac c  subm a,[m] subtract data memory from the accumulator. description the specified data memory is subtracted from the contents of the accumula- tor, leaving the result in the data memory. operation [m]  acc+[m ]+1 affected flag(s) tc2 tc1 to pd ov z ac c  sub a,x subtract immediate data from the accumulator. description the immediate data specified by the code is subtracted from the contents of the accumulator, leaving the result in the accumulator. operation acc  acc+x +1 affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 41 july 18, 2001
swap [m] swap nibbles within the data memory. description the low-order and high-order nibbles of the specified data memory (one of the data memories) are interchanged. operation [m].3~[m].0  [m].7~[m].4 affected flag(s) tc2 tc1 to pd ov z ac c   swapa [m] swap data memory and place result in the accumulator. description the low-order and high-order nibbles of the specified data memory are inter - changed, writing the result to the accumulator. the contents of the data memory remain unchanged. operation acc.3~acc.0  [m].7~[m].4 acc.7~acc.4  [m].3~[m].0 affected flag(s) tc2 tc1 to pd ov z ac c   sz [m] skip if data memory is 0. description if the contents of the specified data memory are 0, the following instruction, fetched during the current instruction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if [m]=0 affected flag(s) tc2 tc1 to pd ov z ac c   sza [m] move data memory to acc, skip if 0. description the contents of the specified data memory are copied to the accumulator. if the contents is 0, the following instruction, fetched during the current in - struction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if [m]=0, acc  [m] affected flag(s) tc2 tc1 to pd ov z ac c   ht46r47 rev. 1.40 42 july 18, 2001
sz [m].i skip if bit  i  of the data memory is 0. description if bit  i  of the specified data memory is 0, the following instruction, fetched during the current instruction execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cycles). otherwise proceed with the next instruction (1 cycle). operation skip if [m].i=0 affected flag(s) tc2 tc1 to pd ov z ac c   tabrdc [m] move the rom code (current page) to tblh and data memory. description the low byte of rom code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte transferred to tblh directly. operation [m]  rom code (low byte) tblh  rom code (high byte) affected flag(s) tc2 tc1 to pd ov z ac c   tabrdl [m] move the rom code (last page) to tblh and data memory. description the low byte of rom code (last page) addressed by the table pointer (tblp) is moved to the data memory and the high byte transferred to tblh directly. operation [m]  rom code (low byte) tblh   code (high byte) affected flag(s) tc2 tc1 to pd ov z ac c   xor a,[m] logical xor accumulator with data memory. description data in the accumulator and the indicated data memory perform a bitwise logical exclusive_or operation and the result is stored in the accumulator. operation acc  acc "xor" [m] affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 43 july 18, 2001
xorm a,[m] logical xor data memory with the accumulator. description data in the indicated data memory and the accumulator perform a bitwise logical exclusive_or operation. the result is stored in the data memory. the 0 flag is affected. operation [m]  acc "xor" [m] affected flag(s) tc2 tc1 to pd ov z ac c  xor a,x logical xor immediate data to the accumulator. description data in the accumulator and the specified data perform a bitwise logical ex - clusive_or operation. the result is stored in the accumulator. the 0 flag is affected. operation acc  acc "xor" x affected flag(s) tc2 tc1 to pd ov z ac c  ht46r47 rev. 1.40 44 july 18, 2001
ht46r47 rev. 1.40 45 july 18, 2001 copyright  2001 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek assumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may pres - ent a risk to human life due to malfunction or otherwise. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science-based industrial park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 holtek semiconductor inc. (taipei office) 11f, no.576, sec.7 chung hsiao e. rd., taipei, taiwan tel: 886-2-2782-9635 fax: 886-2-2782-9636 fax: 886-2-2782-7128 (international sales hotline) holtek semiconductor (hong kong) ltd. rm.711, tower 2, cheung sha wan plaza, 833 cheung sha wan rd., kowloon, hong kong tel: 852-2-745-8288 fax: 852-2-742-8657 holtek semiconductor (shanghai) ltd. 7th floor, building 2, no.889, yi shan rd., shanghai, china tel: 021-6485-5560 fax: 021-6485-0313 holmate technology corp. 48531 warm springs boulevard, suite 413, fremont, ca 94539 tel: 510-252-9880 fax: 510-252-9885


▲Up To Search▲   

 
Price & Availability of HT46R4718DIP-A

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X